package com.gylang.print.pdf.domain.component;

import com.gylang.print.pdf.domain.PdfPageWrapper;
import com.gylang.print.pdf.enums.AlignEnums;
import lombok.Builder;
import lombok.Data;

/**
 * @author gylang
 * data 2021/6/4
 */
@Data
public class BasePdfComponent {


	protected PdfPageWrapper pageWrapper;

	/** 类型 */
	protected final String type;
	/** 宽度 */
	protected float width = 500;

	/** 长度 */
	protected float height;

	/** x轴开始 */
	protected float x;


	/** y轴开始 */
	protected float y;


	/** x轴左外边距 */
	protected float marginLeftX;

	/** x轴右外边距 */
	protected float marginRightX;

	/** y轴顶部外边距 */
	protected float marginTopY;

	/** y轴底部外边距 */
	protected float marginBottomY;


	/** 排列 */
	@Builder.Default
	protected AlignEnums align = AlignEnums.ABSOLUTE;


	/**
	 * x,y宽高
	 *
	 * @param x
	 * @param y
	 * @param width
	 * @param height
	 * @param align  定位
	 */
	public void fixSize(float width, float height, AlignEnums align, float x, float y) {
		this.width = width;
		this.height = height;
		this.x = x;
		this.y = y;
		this.align = align;
	}

	/**
	 * x,y宽高
	 *
	 * @param x
	 * @param y
	 * @param align  定位
	 */
	public void autoSize(AlignEnums align, float x, float y) {
		this.x = x;
		this.y = y;
		this.align = align;
	}


	public BasePdfComponent(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}

	public void setPageWrapper(PdfPageWrapper pageWrapper) {
		this.pageWrapper = pageWrapper;
	}


	public PdfPageWrapper getPageWrapper() {
		return pageWrapper;
	}
}
